<!DOCTYPE html>
<html>
  <head>
    <title>开灯</title>
     <meta charset="utf-8">
     <link rel="icon" href="favicon.ico">
     <meta  name="viewport" content="width=device-width" /> 
  </head>
   
<body>
 <img id="pic"  src="pic_bulboff.gif" />
 <button onclick="KaiDeng()">开/关</button>
 
<script>
  var i=1;
  function KaiDeng(){
    if(i == 1){
       pic.src = "pic_bulboff.gif";
       i = 0;
    }else{
       pic.src = "pic_bulbon.gif";
       i = 1;
    }
  }
 </script>
</body>
</html>